// 封装评论相关请求
import request from '@/utils/request.js'

/**
 * 获取评论
 * @param {Object} params
 * @returns promise
 */
export const getCommentList = params => {
  return request({
    method: 'GET',
    url: '/v1_0/comments',
    params
  })
}

/**
 * 评论点赞
 * @param {*} id 评论id
 * @returns
 */
export const addCommentLiking = id => {
  return request({
    method: 'POST',
    url: '/v1_0/comment/likings',
    data: {
      target: id
    }
  })
}

/**
 * 取消点赞
 * @param {*} id
 * @returns
 */
export const deleteCommentLiking = id => {
  return request({
    method: 'DELETE',
    url: '/v1_0/comment/likings/' + id
  })
}

/**
 * 发布文章评论
 * @param {Object} data {target 评论目标id,content评论内容,art_id 文章id}
 * @returns
 */
export const postComment = data => {
  return request({
    method: 'POST',
    url: '/v1_0/comments',
    data
  })
}
